package com.wm.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.dom4j.io.SAXReader;

import com.alibaba.fastjson.JSON;
import com.wm.bean.Comment;
import com.wm.bean.Restaurant;
import com.wm.bean.User;
import com.wm.service.CommentService;
import com.wm.service.RestaurantService;
import com.wm.vo.CommentListVO;

public class initialAction extends DispatchAction{
	@Resource RestaurantService restaurantService;
	/***
	 * 
	* 取得所有的评论数据
	* 
	*/
	public void getAllComments(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{
		System.out.println("------getallCommentsacton");
		
		
		//return mapping.findForward("comment");

	}
	
	
	
	/**
	 * 初始化首页饭店展示
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */

	public void iinitRest(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{
		
		String uid = request.getParameter("uid");
		
		
		List<Restaurant> rList = restaurantService.getRestByHql(uid);
		String restlistJson = JSON.toJSONString(rList); 
		System.out.println(restlistJson);
		
		//返回前台，显示评论
		response.setContentType("text/xml;charset=UTF-8");  
		response.setHeader("Cache-Control", "no-cache");   
		PrintWriter returnValue=response.getWriter();   
		String output = restlistJson;
		
		 returnValue.print(output);   
		 returnValue.close();   
		
	}
}
